Skip to content

Fix extra incorrectly shown on installation error - #13659

Open
sepehr-rs wants to merge 25 commits into
pypa:mainfrom
sepehr-rs:fix-extras
Open

Fix extra incorrectly shown on installation error#13659
sepehr-rs wants to merge 25 commits into
pypa:mainfrom
sepehr-rs:fix-extras

Conversation

@sepehr-rs

@sepehr-rs sepehr-rs commented Nov 20, 2025

Copy link
Copy Markdown
Member

Fixes #13618
This resolves the issue, though I’m not certain it’s the ideal place for the fix. If needed, we can move the solution further down in the stack.

@notatallshaw

notatallshaw commented Nov 21, 2025

Copy link
Copy Markdown
Member

I've not spent any time looking at the code, but I would be pretty nervous about removing the marker information until right before the error message.

Even if that marker information isn't used now someone might want to use it later and be surprised to find all marker information stripped, and there's no comment as to why that happened.

@sepehr-rs

Copy link
Copy Markdown
Member Author

I've not spent any time looking at the code, but I would be pretty nervous about removing the marker information until right before the error message.

Even if that marker information isn't used now someone might want to use it later and be surprised to find all marker information stripped, and there's no comment as to why that happened.

Thanks for the review, @notatallshaw!
I moved the change further down so the marker info is preserved internally and only stripped at error-message time.

@notatallshaw notatallshaw added this to the 26.0 milestone Nov 30, 2025
@ichard26
ichard26 requested a review from notatallshaw January 11, 2026 20:09

@notatallshaw notatallshaw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the test test_install_special_extra in tests/functional/test_install_extras.py to include something like this at the end:

    assert "No matching distribution found for missing_pkg" in result.stderr, str(result)
    assert "extra ==" not in result.stderr, str(result)

Then I think you're going to find two situations you're not handeling right now:

  1. When the requirement has a parent, you need to move your string manipulation to the top of _report_single_requirement_conflict so it also gets applied to the req_disp variable for logging
  2. The logging and raising of raise DistributionNotFound in PackagingFinder.find_requirement in src/pip/_internal/index/package_finder.py

@notatallshaw

Copy link
Copy Markdown
Member

I'm realizing I wrote the above comment in a bit of a rush and I've not verified the output is actually misleading in that test. So feel free to correct me if I made a mistake, I'll take a other look in the next few days when I have time to review again.

@notatallshaw

Copy link
Copy Markdown
Member

I'm going to move this to 26.1 milestone, I'm generally happy with this approach, but it needs tests, either as new or modified existing ones, and I don't see a rush to get it out (this error has been confusing for a long time).

@notatallshaw notatallshaw modified the milestones: 26.0, 26.1 Jan 28, 2026
@sepehr-rs

Copy link
Copy Markdown
Member Author

Hi @notatallshaw, thanks for the review. Sorry for the delay. I’ve updated the code and tests based on your feedback. Would appreciate another look when you have a moment.
Thanks again!

@danielhollas danielhollas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a pip developer, but hopefully some helpful review comments...

Also this needs more tests I think, right now it seems that only one of the two modified paths is tested?

Comment thread tests/functional/test_install_extras.py
Comment thread src/pip/_internal/resolution/resolvelib/factory.py Outdated
Comment thread src/pip/_internal/index/package_finder.py Outdated
@sepehr-rs

Copy link
Copy Markdown
Member Author

Hi @danielhollas, thanks a lot for the helpful review! I've addressed your comments, but I’m not entirely clear on your note about the assertion test. Could you clarify what you meant?

@danielhollas danielhollas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sepehr-rs thanks. You can disregard my test assertion comment, but I think there's still an issue with how you override req_disp variable.

Comment thread src/pip/_internal/resolution/resolvelib/factory.py Outdated
Comment thread src/pip/_internal/resolution/resolvelib/factory.py Outdated
@notatallshaw

Copy link
Copy Markdown
Member

I took a quick look at this danielhollas's comments all look correct to me.

@sepehr-rs

Copy link
Copy Markdown
Member Author

Hi, sorry for the delay. Things have been hectic over here in Iran and I only recently got access to GitHub again. I’ve committed the changes proposed by @danielhollas. Please let me know what you think!

@notatallshaw notatallshaw modified the milestones: 26.1, 26.2 Apr 24, 2026
@notatallshaw

Copy link
Copy Markdown
Member

Sorry, I think this PR still needs some more review and work, but I'm very unlikely to have time to review before 26.1.

@danielhollas danielhollas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things have been hectic over here in Iran and I only recently got access to GitHub again.

Oof, what an understatement, I am very sorry. :-(

Thank you for the changes, I think that there is at least one thing that needs fixing, otherwise looks reasonable to me, but I am not a pip maintainer, just trying to help with a review :-)

Comment thread src/pip/_internal/resolution/resolvelib/factory.py Outdated
Comment thread src/pip/_internal/index/package_finder.py Outdated
Comment thread src/pip/_internal/resolution/resolvelib/factory.py Outdated
@sepehr-rs

Copy link
Copy Markdown
Member Author

Gentle ping. I believe I've addressed all review comments and follow-up feedback. I think this may be ready for another review. I'd appreciate any feedback when someone has time.

@danielhollas danielhollas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but not a pip maintainer. :-)

@ichard26
ichard26 requested a review from notatallshaw May 30, 2026 23:47
@ichard26

Copy link
Copy Markdown
Member

@notatallshaw I'll leave the review to you. I'm not a fan of using regex substitution, but on a quick glance, it doesn't seem like the packaging marker API allows us to filter out extra markers easily...

@ichard26 ichard26 modified the milestones: 26.2, 26.3 Jul 24, 2026
@ichard26

Copy link
Copy Markdown
Member

I'm deferring this to pip 26.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

extra incorrectly shown on installation error

4 participants